package com.lebang.service.sys;

import com.lebang.component.RedisClient;
import com.lebang.domain.RegisterWhiteImei;
import com.lebang.example.RegisterWhiteImeiExample;
import com.lebang.mapper.RegisterWhiteImeiMapper;
import com.lebang.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 常用渠道设置
 *
 * @Author xwj
 * @Date 2020-06-03
 */
@Service
public class RegisterWhiteImeiService extends BaseService<RegisterWhiteImei, Long, RegisterWhiteImeiExample> {
    @Autowired
    private RegisterWhiteImeiMapper registerWhiteImeiMapper;
    @Autowired
    private RedisClient redisClient;
    public static final String REGISTER_WHITE_IMEI = "REGISTER_WHITE_IMEI";
    
    public Boolean getImei(String imei){
        if (redisClient.hexists(REGISTER_WHITE_IMEI,imei)){
            return true;
        }
        Integer check=registerWhiteImeiMapper.selectByImei(imei);
        if (check != null){
            redisClient.hset(REGISTER_WHITE_IMEI,imei, "1");
            return true;
        }
        return false;
    }

}
